/***************************************************************************
 *   mgpi_engine.h - Engine state definitions                              *
 *   Copyright (C) 2008 by cmaster.matso (Maciej Kad�ubowski)              *
 *   cmaster.matso@gmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef _ENGINE_H
#define _ENGINE_H

#ifdef __cplusplus
extern "C" {
#endif

#include "mgpi_roeskva.h"

static rendnode_t s_pRenderingArray[MGPI_MAX_RENDERING_OBJECTS];                /** rendering nodes array */
static rendnode_t *s_pRenderingList = NULL;                                     /** rendering list pointer */
static rendnode_t *s_pAuxPointer = NULL;                                        /** auxiliary rendering node pointer */
static rendnode_t s_oFramebufferNode;                                           /** rendering node for framebuffer usage */
static effect_t s_pPPEffect;													/** postprocessing effect object */
static struct _void_ptr s_aDispatchBuffer[2] = { 0, 0 };						/** engine multi-threading dispatch double buffer */

static unsigned int s_uiLock = 1;												/** engine multi-threading communication lock */
static int s_nFree = 0;                                                         /** first not used node of the above */
static int s_nListFlag = 0;                                                     /** rendering list usage flag - 0 not used, 1 otherwise*/
static int s_nAnimStart = -1;                                                   /** animation starting point index */
static int s_nAnimStop = -1;                                                    /** animation stoping point index */
static int s_nNumPasses = 1;                                                    /** number of passes in composition */
static int s_nEngineSetup = MGPI_SETUP_DEFAULT;                                 /** engine setup mode flag */
static int s_nMaxAttachments = 2;                                               /** max number of above attachments, hardware dependent */
static int s_nFramebuffersNumber = 0;                                           /** used engine framebuffers number */
static int s_nSamplesUsed = 4;													/** samples used in multisampling antialiasing */
static int *s_vSections[8];                                                     /** array of engine [sections] */
static int s_nSelectedSection = MGPI_DEFAULT;                                   /** used [section] selector */
static int s_nScreenWidth;                                                      /** SDL display context surface width */
static int s_nScreenHeight;                                                     /** SDL display context surface height */
static int s_nPPTextures[4] = { -1, -1, -1, -1 };								/** postprocessing texture names array */

static GLbitfield s_fClearFlags = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;    /** GL buffers clearing bitfield flags */
static GLuint s_aFramebuffers[MGPI_MAX_FRAMEBUFFERS];                           /** engine framebuffers array (?) */
static GLuint *s_aAttachments[MGPI_MAX_FRAMEBUFFERS];                           /** framebuffers attachments array (?) */
static GLuint s_nDepthFormat = GL_DEPTH_COMPONENT32;							/** internal format of the depth renderbuffer */
static GLuint s_nColorFormat = GL_RGBA;											/** internal format of the color renderbuffer (multisampling) */
static GLuint s_nMainProgramID = 0;                                             /** engine main GPU program handle (?) */
static GLuint s_nSelectedProgramID = 0;                                         /** engine selected GPU program handle */

static SDL_Surface *s_pDisplayContext = NULL;                                   /** SDL display context surface pointer */
static const SDL_VideoInfo *s_cpInfo = NULL;                                    /** SDL video info reference */

static MGPI_BOOL s_fTexturingFlag = MGPI_TRUE;                                  /** texturing ON/OFF flag */
static MGPI_BOOL s_fUseShaders = MGPI_FALSE;                                    /** shaders ON/OFF flag */
static MGPI_BOOL s_fUsePrecompiledShaders = MGPI_FALSE;                         /** prcompiled shaders ON/OFF flag */
static MGPI_BOOL s_fUseLight = MGPI_FALSE;                                      /** lighting ON/OFF flag */
static MGPI_BOOL s_fIsInUse = MGPI_FALSE;                                       /** engine start state flag */
static MGPI_BOOL s_fIsFullScreen = MGPI_FALSE;                                  /** fullscreen ON/OFF flag */
static MGPI_BOOL s_fBlockCommands = MGPI_FALSE;                                 /** engine GL commands blocing flag */
static MGPI_BOOL s_fDoMultipassProcess = MGPI_FALSE;							/** multipass prosprocessing flag */

static int (*s_pRenderUserDefined)(rendnode_t *) = NULL;                        /** user defined rendering routine pointer */
static void (*s_pUserSetup)(void) = NULL;                                       /** user defined engine setup routine pointer */
	
#ifdef __cplusplus
}
#endif

#endif
